package com.rockcent.service;

import com.rockcent.common.common.PageResult;
import com.rockcent.common.domain.enumclass.Whether;
import com.rockcent.mall.lib.domain.IntegrationCashCouponWallet;
import com.rockcent.mall.lib.domain.MallCashCoupon;
import com.rockcent.mall.lib.dto.IntegrationCashCouponWalletDto;
import com.rockcent.mall.lib.dto.IntegrationChannelDto;
import com.rockcent.mall.lib.dto.IntegrationCouponDetailRespDto;
import com.rockcent.mall.lib.dto.IntegrationCouponRespDto;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by zhangjh on 2016/12/14.
 */
public interface IntegrationCashCouponWalletSrv {
    //    String RESOURCE_PATH_INTEGRATION_CHANNEL_CASH_DETAIL = "templates/integration_channel_detail.xls";
    String RESOURCE_PATH_INTEGRATION_CHANNEL_CASH_DETAIL_DYNAMIC = "templates/integration_channel_detail_dynamic.xls";
    String SUFFIX_XLSX = ".xls";


    /**
     * queryCashWalletList
     *
     * @param useNum
     * @param customerId
     * @return
     */
    PageResult<IntegrationCashCouponWallet> queryCashWalletList(Long useNum, Long customerId, PageResult pageResult);

    /**
     * 查询总记录数
     *
     * @param useNum
     * @param customerId
     * @return
     */
    Long queryCashWalletCount(Long useNum, Long customerId);

    /**
     * @param exchangeCode
     * @param exchangeNum
     * @param receiveNum
     * @param useNum
     * @return
     */
    IntegrationCashCouponWallet findByExchangeCodeAndExchangeNumAndReceiveNumAndUseNum(String exchangeCode, long exchangeNum, long receiveNum, long useNum);

    /**
     * @param integrationCashCouponWallet
     * @return
     */
    IntegrationCashCouponWallet save(IntegrationCashCouponWallet integrationCashCouponWallet);

    /**
     * @param mallCashCoupon
     */
    void save(MallCashCoupon mallCashCoupon);

    /**
     * @param discountAmount
     * @param userId
     * @param mallId
     * @return
     */
    IntegrationCashCouponWallet getCloseToCashCoupon(BigDecimal discountAmount, Long userId, Long mallId);

    /**
     * @param mallCashCoupon
     * @param mallId
     */
    void update(MallCashCoupon mallCashCoupon, Long mallId);

    /**
     * @param mallCashCoupon
     * @param mallId
     */
    void stop(MallCashCoupon mallCashCoupon, Long mallId);

    /**
     * @param cashCouponId
     * @param integrationChannelId
     * @param mallId
     * @return
     */
    IntegrationCashCouponWallet caculateCash(Long cashCouponId, Long integrationChannelId, Long mallId);

    /**
     * @param name
     * @param mallId
     * @param no
     * @param page
     * @return
     */
    PageResult<IntegrationCashCouponWalletDto> findChannelCashDetail(IntegrationChannelDto name, Long mallId, Whether no, PageResult page);

    /**
     * @param dto
     * @param mallId
     * @param no
     * @return
     */
    Long qrExchangeNumByChannelId(IntegrationChannelDto dto, Long mallId, Whether no);

    /**
     * @param request
     * @param response
     * @param dto
     * @param mallId
     * @param no
     * @throws IOException
     * @throws InvalidFormatException
     */
    void exportExchangeCash(HttpServletRequest request, HttpServletResponse response, IntegrationChannelDto dto, Long mallId, Whether no) throws IOException, InvalidFormatException;

    /**
     * @param channelId
     * @return
     */
    List<IntegrationCouponRespDto> queryList(Long channelId);

    /**
     * @param exchangeCode
     * @return
     */
    IntegrationCashCouponWallet findByExchangeCode(String exchangeCode);


    /**
     * @param exchangeCode
     * @param channelId
     * @param no
     * @param exchangeNum
     * @return
     */
    IntegrationCashCouponWallet findByExchangeCodeAndIntegrationChannelIdAndIsDeleteAndExchangeNum(String exchangeCode, long channelId, Whether no, long exchangeNum);

    /**
     * @param exchangeNum
     * @param cashCouponId
     * @param mallId
     * @param whether
     * @return
     */
    Long countByExchangeNumAndCashCouponIdAndMallIdAndIsDelete(Long exchangeNum, Long cashCouponId, Long mallId, Whether whether);

    /**
     * @param dto
     * @param mallId
     * @param no
     * @return
     */
    Double qrExchangeNumCashAmountByChannelId(IntegrationChannelDto dto, Long mallId, Whether no);

    /**
     * @param cashCouponId
     * @return
     */
    List<IntegrationCouponDetailRespDto> findByCashCounponId(Long cashCouponId);

    /**
     *
     * @param exchangeCode
     * @param integrationChannelId
     * @param no
     * @return
     */
    IntegrationCashCouponWallet findByExchangeCodeAndIntegrationChannelIdAndIsDelete(String exchangeCode, Long integrationChannelId, Whether no);

    /**
     *
     * @param faceVal
     * @param integrationChannelId
     * @param whether
     * @param exchangeNum
     * @return
     */
    IntegrationCashCouponWallet findTop1ByFaceValueAndIntegrationChannelIdAndIsDeleteAndExchangeNum(BigDecimal faceVal, Long integrationChannelId, Whether whether, long exchangeNum);

    /**
     * 现金券领取完毕发消息
     * @param mallId
     * @param mallCashCouponId
     */
    void findCashCouponWalletPushReceiveOverMsg(Long mallId, Long mallCashCouponId) throws Exception;

    /**
     * 现金券使用完毕发消息
     * @param mallId
     * @param mallCashCouponId
     */
    void findCashCouponWalletPushUseOverMsg(Long mallId, Long mallCashCouponId) throws Exception;
}
